Repository navigation
Conversation
Keep the 0.2 request builder behind an explicit legacy layout. Migrate the Program translator and examples, and verify role boundaries, repair, workspace resolution, and packaged consumers with deterministic models. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 24, 2026
robgruen
marked this pull request as ready for review
November 24, 2026 17:13
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the schema-first prompting changes and their legacy migration path.
No open issues 🎉
1 file not reviewed
typescript/package-lock.json: Generated file
What changed in this PR
Implements the TypeScript candidate for #539’s proposed 0.3 schema-first prompting, with an explicit legacy migration path. The changes cover the library, examples, and documentation; they do not publish a package.
Changes:
- Separate system instructions and schema from the verbatim user request, preserving caller context roles.
- Migrate Program and example prompts, and align package versions and example dependencies.
- Add prompt-layout, repair, example, and package-consumer checks alongside migration guidance.
| File | Description |
|---|---|
typescript/tests/package.test.mjs |
Checks published prompt APIs and default message layout. |
typescript/tests/examples.test.mjs |
Checks workspace resolution and migrated example prompts. |
typescript/test/prompt-layout.test.ts |
Covers default, legacy, history, and migration-error behavior. |
typescript/test/program.test.ts |
Checks Program schemas, layouts, and repair messages. |
typescript/test/failure.test.ts |
Verifies repair roles and original response preservation. |
typescript/src/typechat.ts |
Adds schema-first defaults, system builder, and legacy option. |
typescript/src/ts/program.ts |
Adapts Program prompts to both layouts. |
typescript/src/model.ts |
Updates comments describing prompt roles and adapter expectations. |
typescript/README.md |
Documents 0.3 prompts and migration. |
typescript/package.json |
Sets the candidate version to 0.3.0. |
typescript/package-lock.json |
Aligns root and example dependency versions. |
typescript/examples/sentiment/package.json |
Targets TypeChat 0.3. |
typescript/examples/sentiment-zod/package.json |
Targets TypeChat 0.3. |
typescript/examples/restaurant/package.json |
Targets TypeChat 0.3. |
typescript/examples/music/package.json |
Targets TypeChat 0.3. |
typescript/examples/multiSchema/src/router.ts |
Moves classification instructions into the system prompt. |
typescript/examples/multiSchema/package.json |
Targets TypeChat 0.3. |
typescript/examples/math/package.json |
Targets TypeChat 0.3. |
typescript/examples/healthData/src/translator.ts |
Separates application instructions from assistant history. |
typescript/examples/healthData/package.json |
Targets TypeChat 0.3. |
typescript/examples/drawing/src/main.ts |
Passes prior requests as user-context sections. |
typescript/examples/drawing/package.json |
Targets TypeChat 0.3. |
typescript/examples/crossword/src/translator.ts |
Separates system instructions, screenshot context, and request. |
typescript/examples/crossword/package.json |
Targets TypeChat 0.3. |
typescript/examples/coffeeShop/package.json |
Targets TypeChat 0.3. |
typescript/examples/coffeeShop-zod/package.json |
Targets TypeChat 0.3. |
typescript/examples/calendar/package.json |
Targets TypeChat 0.3. |
site/src/docs/typescript/basic-usage.md |
Explains layouts, context, migration, and repair behavior. |
Review effort: Balanced
TypeScript now makes the same one repair attempt as Python and TypeChat.NET when a reply has no JSON object or cannot be parsed. Validation failures still repair once, and attemptRepair = false still returns immediately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Missing or malformed JSON now triggers a second model call by default, adding latency and usage instead of preserving TypeScript’s immediate-failure behavior.
1 open issue
1 file not reviewed
typescript/package-lock.json: Generated file
Review effort: Balanced
| const validation = schemaValidation.success ? typeChat.validateInstance(schemaValidation.data) : schemaValidation; | ||
| if (validation.success) { | ||
| return finish(validation); | ||
| else if (!attemptRepair) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Implement the TypeScript candidate for the one-time 0.3.x behavior proposed in #539, alongside Guido’s Python #241. Please hold merge until the project-direction proposal is approved and merged.
On a fresh request the translator submits application-owned instructions and schema as
system, followed by the verbatim request once asuser. Caller context keeps its roles.{ promptLayout: "legacy" }preserves the previous request builder and layout; an unmigrated request override is reported before dispatch rather than promoted to system text or silently skipped.The Program translator describes both the JSON program to return and the API it can call. The affected examples, migration docs, package version, and example dependency ranges are updated. This does not change the other languages’ APIs or publish a package.
Verified locally on Node 24.22.1:
npm ci,npm run build-all,npm test(433 passing, including 13 package-consumer checks), all 12 examples resolved the candidate workspace, and the docs site built. A separately installednpm packtarball passed the same offline message check as Python: fresh request, follow-up with history, forced validation repair, and validated final result.